package day07;

import java.util.Scanner;

public class txt4 {
    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的元素:");
        int ele = sc.nextInt();
        int index =findEle(a, ele);
        System.out.println(index>=0?index:"没找到");
    }

    static int findEle(int[] a, int ele) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] == ele) {
                System.out.println("找到元素");
                return i;
            }
        }
        return -2;
    }
}


